﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Xml;

//DODGY CLASS N.B
//DODGY CLASS N.B
//DODGY CLASS N.B
//DODGY CLASS N.B
//DODGY CLASS N.B
namespace CarlowPitBoy
{
    class MapSave
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mapName"></param>
        /// <param name="mapCoord"></param>
        public void saveBackground(String mapName, Point mapCoord)
        {
            try
            {
                XmlTextWriter backgroundSaver = new XmlTextWriter(mapCoord.X.ToString() + "," + mapCoord.Y.ToString() + " " + mapName + ".xml", null);
                backgroundSaver.Formatting = Formatting.Indented;
                backgroundSaver.WriteStartDocument();
                //info save
                backgroundSaver.WriteEndDocument();
                backgroundSaver.Flush();
                backgroundSaver.Close();
                System.Windows.Forms.MessageBox.Show("The file " + mapCoord.X.ToString() + "," + @mapCoord.Y.ToString() + " " + mapName + ".xml" + " has been saved successfully.");

            }
            catch (Exception unknownEx)
            {
                System.Windows.Forms.MessageBox.Show(unknownEx.ToString());
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mapName"></param>
        /// <param name="mapCoord"></param>
        public void saveTerrain(String mapName, Point mapCoord)//, terrain properties);
        {
            try
            {
                XmlTextWriter backgroundSaver = new XmlTextWriter(mapCoord.X.ToString() + "," + mapCoord.Y.ToString() + " " + mapName + ".xml", null);
                backgroundSaver.Formatting = Formatting.Indented;
                backgroundSaver.WriteStartDocument();
                //info save
                backgroundSaver.WriteEndDocument();
                backgroundSaver.Flush();
                backgroundSaver.Close();
                System.Windows.Forms.MessageBox.Show("The file " + mapCoord.X.ToString() + "," + @mapCoord.Y.ToString() + " " + mapName + ".xml" + " has been saved successfully.");

            }
            catch (Exception unknownEx)
            {
                System.Windows.Forms.MessageBox.Show(unknownEx.ToString());
            }
        }
    }
}
